import fs from "fs"

const fileUtil = {
    readFile: async (path = './data.json') => {
        // 读取文件
        const data = await fs.promises.readFile(path, 'utf-8')
        return JSON.parse(data)
    },

    writeFile: async (path = './data.json', data) => {
        // 写入文件
        await fs.promises.writeFile(path, JSON.stringify(data))
    }
}



export default fileUtil